package com.cqjtu.eecs.mapper;

import com.cqjtu.eecs.entity.RolePermission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cqjtu.eecs.entity.vo.RouterVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 角色-权限 Mapper 接口
 * </p>
 *
 * @author     luojun
 * @since 2022-03-04
 */
@Mapper
@Repository
public interface RolePermissionMapper extends BaseMapper<RolePermission> {
    // 通过roleIdList获取对应的权限idList
    List<Integer> listPermissionIdListByRoleIdList(@Param("ids") List<Integer> ids);

    /**
     * 根据uid获取用户所属角色的权限路由
     * @param uid
     * @return
     */
    Set<RouterVo> getUserRolePermission(Integer uid);
    // 根据roleId和PermissionIdList删除
    Integer deleteByRidAndPid(@Param("roleId")Integer roleId,@Param("pIds")List<Integer> pIds);
    // 批量插入
    Integer saveBath(@Param("permissions")List<RolePermission> permissions);
}
